/* indent size: 2 */

module.exports = app => {
  const DataTypes = app.Sequelize;

  const Model = app.model.define('borrows', {
    borrow_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      primaryKey: true,
      autoIncrement:true
    },
    depart_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      references: {
        model: 'department',
        key: 'department_id'
      }
    },
    student_number: {
      type: DataTypes.STRING(12),
      allowNull: false
    },
    student_name: {
      type: DataTypes.STRING(50),
      allowNull: false
    },
    phone: {
      type: DataTypes.STRING(12),
      allowNull: false
    },
    borrow_items: {
      type: DataTypes.STRING(500),
      allowNull: false
    },
    borrow_count: {
      type: DataTypes.INTEGER(4),
      allowNull: false
    },
    borrow_time: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: DataTypes.literal('CURRENT_TIMESTAMP')
    },
    return_time: {
      type: DataTypes.DATE,
      allowNull: true
    }
  }, {
    tableName: 'borrows'
  });

  Model.associate = function() {

  }

  return Model;
};
